/**
 * Created by Administrator on 2017/4/8 0008.
 */
//初始化字符大小fontsize=20px
function setRem(){
    var docEl = document.documentElement;
    var deviceWidth = docEl.clientWidth;
    var dpr = window.devicePixelRatio;
    var scale = 1 / dpr; // 如果我们做到 dip 和物理像素 1:1
    var metaEl = document.createElement('meta');
    metaEl.setAttribute('name', 'viewport');
    metaEl.setAttribute('content', 'width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=0,initial-scale=' + scale);
    docEl.firstElementChild.appendChild(metaEl);
    // 给 html 添加 font-size 和 data-dpr
    docEl.style.fontSize = document.documentElement.clientWidth/ 18.75 + 'px';
    docEl.setAttribute('data-dpr', dpr);
};
window.onresize = function(){
    setRem();
};
setRem();
